package com.dliu.javadesign.structure.bridge;

/**
 * 电脑类型+名牌
 * @author yanglei
 * date 2021/3/30 16:46
 */
public abstract class Computer {
    protected Brand brand;

    protected Computer(Brand brand){
        this.brand = brand;
    }

    abstract String getType();


    static class Desktop extends Computer {

        protected Desktop(Brand brand) {
            super(brand);
        }

        @Override
        String getType() {
            return brand.getName() + "台式电脑";
        }
    }

    static class NoteBook extends Computer {

        protected NoteBook(Brand brand) {
            super(brand);
        }

        @Override
        String getType() {
            return brand.getName() + "笔记本电脑";
        }
    }

    public static void main(String[] args) {
        Desktop desktop = new Desktop(new Brand.Apple());
        System.out.println(desktop.getType());

        NoteBook noteBook = new NoteBook(new Brand.Huawei());
        System.out.println(noteBook.getType());
    }
}
